﻿using UnityEngine;
using System.Collections;


public class EventDispatchCenter : MonoSingleton<EventDispatchCenter> {

	protected EventDispatcher _dispatcher;

	void Awake(){
		_dispatcher = new EventDispatcher (this);
	}

	void Start () {
	}

	public bool addEventListener (string aEventName_string, EventDelegate aEventDelegate)
	{
		return addEventListener (aEventName_string, aEventDelegate, EventDispatcherAddMode.DEFAULT);
	}

	public bool addEventListener (string aEventName_string, EventDelegate aEventDelegate, EventDispatcherAddMode aEventDispatcherAddMode)
	{
		return _dispatcher.addEventListener (aEventName_string, aEventDelegate, aEventDispatcherAddMode);
	}

	public bool hasEventListener (string aEventName_string, EventDelegate aEventDelegate)
	{
		return _dispatcher.hasEventListener (aEventName_string, aEventDelegate);
	}

	public bool removeEventListener (string aEventName_string, EventDelegate aEventDelegate)
	{
		return _dispatcher.removeEventListener (aEventName_string, aEventDelegate);
	}

	public bool dispatchEvent (IEvent aIEvent)
	{
		return _dispatcher.dispatchEvent (aIEvent);
	}

	public bool dispatchEvent (string eventType, object eventData)
	{
		return _dispatcher.dispatchEvent (new GenericEvent(eventType, eventData));
	}

}


public class GenericEvent : BaseEvent {

	public object data {
		get;
		set;
	}

	public GenericEvent (string eventType, object eventData) : base(eventType) {
		data = eventData;
	}

}
